package nspel

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/logs"
)

type Logger struct {
	Enable      bool
	FileName    string
	IsConsole   bool
	FuncCall    bool
	Async       bool
	AsyncMsgLen int64
}

func LoggerInit(filePath string) {
	var logger Logger
	parseJson(filePath, &logger)
	if logger.Enable {
		beego.SetLogger("file", `{"filename":"`+logger.FileName+`"}`)
		if !logger.IsConsole {
			beego.BeeLogger.DelLogger("console")
		}
		if logger.FuncCall {
			beego.SetLogFuncCall(true)
		}
		if logger.Async {
			logs.Async(logger.AsyncMsgLen)
		}
	}
}

func Debug(arg0 interface{}, args ...interface{}) {
	logs.Debug(arg0)
}

func Error(arg0 interface{}, args ...interface{}) {
	logs.Error(arg0)
}

func Info(arg0 interface{}, args ...interface{}) {
	logs.Info(arg0)
}
